full transcript

From the Ted Talk by Alex Rosenthal: The Tower of Epiphany | Think Like A Coder, Ep 7

Unscramble the Blue Letters

Ethic and Hedge are on the ground floor of a massive toewr. breriras of energy separate them from their quest’s second goal: the Node of Creation. To reach it, eihtc must use three energy streams to clmib the tower. As soon as she steps forward a timer will begin counting down from 60 sceonds. At the back of the room there’s a basin made of invisible towers that can hold energy between them. After one minute, a torrent of energy will pour down from above, filling one unit at a time, with a force field preventing it from spilling out the front or back. During the 60 calm seconds, Ethic and Hedge must diedce exactly how many uitns of energy will fall. For each of the three challenges, they must choose the amount that will fill the basin exactly. If they do so, the energy will propel them further upwards. But if they get the amount at all wrong, the energy lift will fail, dropping them. Diagrams on the wlals illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only orfevolw if there’s no space that could hold it. Hedge can make one tower of blocks visible at a time and count how tall it is, but he can’t look at the whole scurutrte all at once. How does Ethic program Hedge to figure out exactly how much energy each basin can hold? Pause now to fgurie it out for yourself. Here’s one way of thinking about what’s happening: each unoccupied cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many units of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s analyze the problem by looking at our example. There are 5 columns of blocks here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block stacks. We get 3 units by taking the height where the energy would level off— 4, and subtracting the height of the stack— so that’s 4 minus 1. The 3rd stack is similar— 4 to the left, 4 to the right, and it’s 3 high, so it’ll hold 4 minus 3 equals 1 unit. The 4th stcak and 5th stacks have nothing hgiher than them to the right, so they can’t hold any energy. We can apdat this idea into an algorithm. Considering one column at a time as the point of reference, Hedge can look to the left stack by stack to find the hihget of the tallest one, look to the right to find the height of the tlsleat one, and take the smaller of the two as the height the energy can fill up to. If the result is higher than the column in question, subtract the height of the original column, and the rsulet will be the number of units that column can hold. If it's equal to or below the level of the column in queitson, the energy would spill off. Hedge can apply that to an ertnie bsain with a loop that starts on the left-most column and moves right, one column at a time. For each column, he’ll run the same steps— look all the way left for the tallest, do the same to the right, take the lower height of the two, subtract the original column height, and increase the grand total if that number is positive. His loop will repeat as many times as there are columns. That will work, but it’ll take a long time for a large basin. At every step hdgee reateps the action of looking left and looking right. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can satrt on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 4, 4, 4. He can then find the hgeisht right-most stacks by doing the same going right-to-left: 1, 3, 4, 4, 4. In the end he’ll have a table like this in his memory. Now, Hedge can take one more pass to calculate how much egenry there will be above every stack with the same equation from before: take the smaller of the sterod left and right values, and subtract the height of the current tower. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called linear time. There are ways to optimize the soolitun even further, but this is good enough for our heroes. Ethic and Hedge work as one. The first cascade is a bereze, and they rise up the tower. The second is a little tougher. The third is huge, with dozens of stacks of blocks. The temir ticks down towards zero, but Ethic’s parogrm is fast. She gets the weehl in position just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The world machine changed everything, and Ethic, in her position as cehif robotics eegnienr, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously wrong. So she created three aitatrfcs with the aiiblty to rrteose people’s power, creativity, and memory, and smuleggd them to three communities. Before she could tell people how to use them, the government dveosirecd her efforts and sent bots to arsert her and the other programmers. The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the forces of ignorance by enclosing it in a gaint maze. She named her creation Hedge. Without warning, the energy lift flickers, then fizzles out.

Open Cloze

Ethic and Hedge are on the ground floor of a massive _____. ________ of energy separate them from their quest’s second goal: the Node of Creation. To reach it, _____ must use three energy streams to _____ the tower. As soon as she steps forward a timer will begin counting down from 60 _______. At the back of the room there’s a basin made of invisible towers that can hold energy between them. After one minute, a torrent of energy will pour down from above, filling one unit at a time, with a force field preventing it from spilling out the front or back. During the 60 calm seconds, Ethic and Hedge must ______ exactly how many _____ of energy will fall. For each of the three challenges, they must choose the amount that will fill the basin exactly. If they do so, the energy will propel them further upwards. But if they get the amount at all wrong, the energy lift will fail, dropping them. Diagrams on the _____ illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only ________ if there’s no space that could hold it. Hedge can make one tower of blocks visible at a time and count how tall it is, but he can’t look at the whole _________ all at once. How does Ethic program Hedge to figure out exactly how much energy each basin can hold? Pause now to ______ it out for yourself. Here’s one way of thinking about what’s happening: each unoccupied cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many units of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s analyze the problem by looking at our example. There are 5 columns of blocks here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block stacks. We get 3 units by taking the height where the energy would level off— 4, and subtracting the height of the stack— so that’s 4 minus 1. The 3rd stack is similar— 4 to the left, 4 to the right, and it’s 3 high, so it’ll hold 4 minus 3 equals 1 unit. The 4th _____ and 5th stacks have nothing ______ than them to the right, so they can’t hold any energy. We can _____ this idea into an algorithm. Considering one column at a time as the point of reference, Hedge can look to the left stack by stack to find the ______ of the tallest one, look to the right to find the height of the _______ one, and take the smaller of the two as the height the energy can fill up to. If the result is higher than the column in question, subtract the height of the original column, and the ______ will be the number of units that column can hold. If it's equal to or below the level of the column in ________, the energy would spill off. Hedge can apply that to an ______ _____ with a loop that starts on the left-most column and moves right, one column at a time. For each column, he’ll run the same steps— look all the way left for the tallest, do the same to the right, take the lower height of the two, subtract the original column height, and increase the grand total if that number is positive. His loop will repeat as many times as there are columns. That will work, but it’ll take a long time for a large basin. At every step _____ _______ the action of looking left and looking right. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can _____ on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 4, 4, 4. He can then find the _______ right-most stacks by doing the same going right-to-left: 1, 3, 4, 4, 4. In the end he’ll have a table like this in his memory. Now, Hedge can take one more pass to calculate how much ______ there will be above every stack with the same equation from before: take the smaller of the ______ left and right values, and subtract the height of the current tower. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called linear time. There are ways to optimize the ________ even further, but this is good enough for our heroes. Ethic and Hedge work as one. The first cascade is a ______, and they rise up the tower. The second is a little tougher. The third is huge, with dozens of stacks of blocks. The _____ ticks down towards zero, but Ethic’s _______ is fast. She gets the _____ in position just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The world machine changed everything, and Ethic, in her position as _____ robotics ________, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously wrong. So she created three _________ with the _______ to _______ people’s power, creativity, and memory, and ________ them to three communities. Before she could tell people how to use them, the government __________ her efforts and sent bots to ______ her and the other programmers. The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the forces of ignorance by enclosing it in a _____ maze. She named her creation Hedge. Without warning, the energy lift flickers, then fizzles out.

Solution

  1. breeze
  2. height
  3. stored
  4. restore
  5. start
  6. hedge
  7. discovered
  8. ability
  9. question
  10. higher
  11. overflow
  12. tallest
  13. units
  14. timer
  15. seconds
  16. wheel
  17. smuggled
  18. giant
  19. entire
  20. chief
  21. highest
  22. engineer
  23. decide
  24. barriers
  25. artifacts
  26. energy
  27. climb
  28. solution
  29. stack
  30. tower
  31. adapt
  32. arrest
  33. basin
  34. ethic
  35. walls
  36. figure
  37. program
  38. repeats
  39. result
  40. structure

Original Text

Ethic and Hedge are on the ground floor of a massive tower. Barriers of energy separate them from their quest’s second goal: the Node of Creation. To reach it, Ethic must use three energy streams to climb the tower. As soon as she steps forward a timer will begin counting down from 60 seconds. At the back of the room there’s a basin made of invisible towers that can hold energy between them. After one minute, a torrent of energy will pour down from above, filling one unit at a time, with a force field preventing it from spilling out the front or back. During the 60 calm seconds, Ethic and Hedge must decide exactly how many units of energy will fall. For each of the three challenges, they must choose the amount that will fill the basin exactly. If they do so, the energy will propel them further upwards. But if they get the amount at all wrong, the energy lift will fail, dropping them. Diagrams on the walls illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only overflow if there’s no space that could hold it. Hedge can make one tower of blocks visible at a time and count how tall it is, but he can’t look at the whole structure all at once. How does Ethic program Hedge to figure out exactly how much energy each basin can hold? Pause now to figure it out for yourself. Here’s one way of thinking about what’s happening: each unoccupied cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many units of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s analyze the problem by looking at our example. There are 5 columns of blocks here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block stacks. We get 3 units by taking the height where the energy would level off— 4, and subtracting the height of the stack— so that’s 4 minus 1. The 3rd stack is similar— 4 to the left, 4 to the right, and it’s 3 high, so it’ll hold 4 minus 3 equals 1 unit. The 4th stack and 5th stacks have nothing higher than them to the right, so they can’t hold any energy. We can adapt this idea into an algorithm. Considering one column at a time as the point of reference, Hedge can look to the left stack by stack to find the height of the tallest one, look to the right to find the height of the tallest one, and take the smaller of the two as the height the energy can fill up to. If the result is higher than the column in question, subtract the height of the original column, and the result will be the number of units that column can hold. If it's equal to or below the level of the column in question, the energy would spill off. Hedge can apply that to an entire basin with a loop that starts on the left-most column and moves right, one column at a time. For each column, he’ll run the same steps— look all the way left for the tallest, do the same to the right, take the lower height of the two, subtract the original column height, and increase the grand total if that number is positive. His loop will repeat as many times as there are columns. That will work, but it’ll take a long time for a large basin. At every step Hedge repeats the action of looking left and looking right. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can start on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 4, 4, 4. He can then find the highest right-most stacks by doing the same going right-to-left: 1, 3, 4, 4, 4. In the end he’ll have a table like this in his memory. Now, Hedge can take one more pass to calculate how much energy there will be above every stack with the same equation from before: take the smaller of the stored left and right values, and subtract the height of the current tower. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called linear time. There are ways to optimize the solution even further, but this is good enough for our heroes. Ethic and Hedge work as one. The first cascade is a breeze, and they rise up the tower. The second is a little tougher. The third is huge, with dozens of stacks of blocks. The timer ticks down towards zero, but Ethic’s program is fast. She gets the wheel in position just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The world machine changed everything, and Ethic, in her position as chief robotics engineer, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously wrong. So she created three artifacts with the ability to restore people’s power, creativity, and memory, and smuggled them to three communities. Before she could tell people how to use them, the government discovered her efforts and sent bots to arrest her and the other programmers. The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the forces of ignorance by enclosing it in a giant maze. She named her creation Hedge. Without warning, the energy lift flickers, then fizzles out.

Frequently Occurring Word Combinations

ngrams of length 2

collocation frequency
hold energy 2
energy lift 2
wall eventually 2
long time 2
world machine 2

Important Words

  1. ability
  2. action
  3. adapt
  4. algorithm
  5. amount
  6. analyze
  7. ancient
  8. apply
  9. arrest
  10. artifacts
  11. barriers
  12. basin
  13. block
  14. blocks
  15. bots
  16. bradbarrier
  17. breeze
  18. calculate
  19. called
  20. calm
  21. capture
  22. cascade
  23. cell
  24. challenges
  25. changed
  26. check
  27. chief
  28. choose
  29. climb
  30. column
  31. columns
  32. communities
  33. configuration
  34. count
  35. counting
  36. create
  37. created
  38. creation
  39. creativity
  40. current
  41. decide
  42. device
  43. diagrams
  44. discovered
  45. dozens
  46. dropping
  47. efforts
  48. enclosing
  49. energy
  50. engineer
  51. entire
  52. equal
  53. equals
  54. equation
  55. ethic
  56. eventually
  57. examples
  58. fail
  59. fall
  60. fast
  61. faster
  62. field
  63. figure
  64. fill
  65. filling
  66. find
  67. fizzles
  68. flickers
  69. floor
  70. force
  71. forces
  72. front
  73. giant
  74. good
  75. government
  76. grand
  77. grew
  78. ground
  79. hedge
  80. height
  81. heroes
  82. high
  83. higher
  84. highest
  85. hold
  86. huge
  87. idea
  88. ignorance
  89. illustrate
  90. increase
  91. individual
  92. instance
  93. invisible
  94. knew
  95. large
  96. left
  97. leftmost
  98. level
  99. lift
  100. lifts
  101. linear
  102. long
  103. loop
  104. machine
  105. massive
  106. maze
  107. memories
  108. memory
  109. minute
  110. moves
  111. named
  112. node
  113. number
  114. optimize
  115. original
  116. overflow
  117. pass
  118. pause
  119. people
  120. point
  121. position
  122. positive
  123. pour
  124. power
  125. preventing
  126. problem
  127. program
  128. programmers
  129. propel
  130. protect
  131. question
  132. rain
  133. reach
  134. reference
  135. repeat
  136. repeats
  137. restore
  138. result
  139. reveals
  140. rise
  141. robot
  142. robotics
  143. room
  144. run
  145. running
  146. seconds
  147. separate
  148. smaller
  149. smuggled
  150. solution
  151. space
  152. spill
  153. spilling
  154. stack
  155. stacks
  156. start
  157. starts
  158. step
  159. steps
  160. stored
  161. streams
  162. structure
  163. subtract
  164. subtracting
  165. table
  166. tall
  167. tallest
  168. tally
  169. thinking
  170. ticks
  171. time
  172. timer
  173. times
  174. torrent
  175. total
  176. tougher
  177. tower
  178. towers
  179. trapped
  180. troubled
  181. unit
  182. units
  183. unoccupied
  184. values
  185. visible
  186. wall
  187. walls
  188. warning
  189. ways
  190. wheel
  191. work
  192. world
  193. wrong
  194. years